Ext.require([
    'AM.service.Support',
    'AM.component.menu.MenuItemFactory',
    'AM.data.InitConfig'
]);


Ext.define('AM.component.Image', {


    extend:'Ext.Component',


    xtype:'xbxImage',


    constructor:function (config, xbxConfig) {
        var me = this;
        me.callParent(arguments);
        me.initConfig(config);

        me.addListener('render', function () {
            if (!Ext.isEmpty(config)) {
                var file = config.file;
                if (!Ext.isEmpty(file)) {
                    var reader = new FileReader();
                    reader.onload = function(re) {
                        me.el.dom.style['background-image'] = 'url(' + re.target.result + ')';
                    }
                    reader.readAsDataURL(file);
                }

                var src = config.src;
                if (!Ext.isEmpty(src)) {
                    me.el.dom.style['backgroud-image'] = 'url(' + src + ')';
                }
            }

            if (!Ext.isEmpty(xbxConfig)) {
                AM.data.InitConfig.image(me, xbxConfig);
            }

            var sp = AM.service.Support;
            sp.drag(me);
            sp.resize(me);
            sp.contextmenu(me)
            sp.cacheCmp(me);
            sp.animShow(me);

        })
    },

    src:null,

    config: {
        file: null,
        imageName: null
    },

    style:{
        backgroundSize:'100% 100%',
        position:'absolute',
        width:'100px',
        height:'100px'
    }

});